import React from "react";

const Sister = () => {
  return <h1>我是姐姐</h1>;
};
// 
const Son = ({ name, money, clickSum }) => {
  return (
    <div>
      <h1>
        我是子组件{name}
        {money}
        <button
          onClick={() => {
            clickSum(10);
          }}
        >
          带你
        </button>
      </h1>
    </div>
  );
};
class App extends React.Component {
  state = {
    money: 100,
  };
  clickSumFn = (money) => {
    console.log(money);
    this.setState({ money: this.state.money - money });
  };
  render() {
    return (
      <div>
        <h1>我是父亲</h1>
        <h1>{this.state.money}</h1>
        <Son
          name="jack"
          money={this.state.money}
          clickSum={this.clickSumFn}
        ></Son>
        <Sister></Sister>
      </div>
    );
  }
  // 父组件传递方法
}
export default App;
